<!DOCTYPE html>
<html>
<head>
  <title>发送 POST 请求示例</title>
  <meta charset="UTF-8">

  <style>
    body {
      background-color: #f2f2f2; /* 设置整体背景色 */
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
    }
    #inputContainer {
      margin-top: 20px;
      text-align: center;
    }
    input[type="text"] {
      width: 300px;
      height: 30px;
      margin-bottom: 10px;
      border-radius: 5px;
      border: 1px solid #ccc;
      padding: 5px;
      transition: border-color 0.3s ease-in-out; /* 设置鼠标悬停时的动态效果 */
    }
    input[type="text"]:hover {
      border-color: #666;
    }
    button {
      width: 150px;
      height: 40px;
      background-color: #007bff;
      color: #fff;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      transition: background-color 0.3s ease-in-out; /* 设置鼠标悬停时的动态效果 */
    }
    button:hover {
      background-color: #0056b3;
    }
    #response {
      margin-top: 20px;
      padding: 10px;
      border-radius: 5px;
      background-color: #fff;
      box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    }
  </style>
</head>
<body>
<div id="inputContainer">
  <input type="text" id="param1" placeholder="参数1（必填）"><br>
  <input type="text" id="param2" placeholder="参数2（选填）"><br>
  <input type="text" id="param3" placeholder="参数3（选填）"><br>
  <input type="text" id="param4" placeholder="参数4（选填）"><br>
  <input type="text" id="param5" placeholder="参数5（选填）"><br>
  <button onclick="sendRequest()">发送请求</button>
</div>

<div id="response"></div>

<script>
  function sendRequest() {
    var param1 = document.getElementById('param1').value;
    var param2 = document.getElementById('param2').value;
    var param3 = document.getElementById('param3').value;
    var param4 = document.getElementById('param4').value;
    var param5 = document.getElementById('param5').value;
    var url = '/auto/commit';
    var data = {
      param1: param1,
      param2: param2,
      param3: param3,
      param4: param4,
      param5: param5
    };

    fetch(url, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(data)
    })
            .then(response => response.json())
            .then(data => {
              var responseDiv = document.getElementById('response');
              if (data.code === 200) {
                if (Array.isArray(data.data)) {
                  var html = '';
                  for (var i = 0; i < data.data.length; i++) {
                    html += data.data[i] + '<br>';
                  }
                  responseDiv.innerHTML = html;
                }
              } else {
                responseDiv.innerHTML = data.message;
              }
            })
            .catch(error => console.error('Error:', error));
  }
</script>
</body>
</html>
